extends "res://tscn/eventDlg/eventItemSel/eventItemSel.gd"


var utils = null

# Called when the node enters the scene tree for the first time.
func _ready():
	._ready()
	utils = sys.get_node("VEBase").utils

func init(num,type = 0,isOnly = true):
	items = ItemGrid.new(num)
	self.isOnly = isOnly
	self.type = type
	for i in num :
		var bt = preload("res://!ve/additional/tiejiang_rewrite/itemSel.tscn").instance()
		$ScrollContainer/HBoxContainer.add_child(bt)
		bt.init(null)
		bt.connect("onSel",self,"r",[bt,i])

func r(bt,inx):
	if bt.item != null:
		bt.item = null
		items.delInxItem(inx)
	var dlg = sys.newDlg("res://!ve/additional/tiejiang_rewrite/selItemDlg.tscn")
	var teamItems = utils.getPlayerTeamItemPck()
	dlg.init(teamItems,type,items,isOnly)
	var item = yield(dlg,"onSel")
	bt.init(item)
	items.addItem(item,inx)
